import { getToken } from '../api/login'
import storageUtils from "../utils/storageUtils"


export default {
    // namespace:"user",
    state: {
        user: [],
    },
    reducers: {
        getUserToken(state, { payload }) {
            storageUtils.setStorage("token", payload.token)
            storageUtils.setStorage("userInfo", payload.user)
            state.token = payload.token
        }
    },
    effects: {
        *getTokens({ payload }, { call, put }) {
            const res = yield call(getToken, payload)
            yield put({ type: "getUserToken", payload: res.data })
        }
    }
}